package com.opal.system.controller;

import com.opal.domain.ReturnMessageData;
import com.opal.model.DataGridData;
import com.opal.system.entity.*;
import com.opal.system.entity.table.BdDefdoc;
import com.opal.system.entity.table.BdPsndoc;
import com.opal.system.entity.table.OrgDeptExtend;
import com.opal.system.entity.table.OrgHrorg;
import com.opal.system.service.SignCardSingleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/signCardSingle")
public class SignCardSingleController {
	@Autowired
	private SignCardSingleService signCardSingleService;

	/**
	 * 获取所有的组织(oracle)
	 * @return
	 */
	@RequestMapping("/selectAllOrgHrorg")
	@ResponseBody
	public List<OrgHrorg> selectAllOrgHrorg(){
		return signCardSingleService.selectAllOrgHrorgService();
	}


	@RequestMapping("/selectAllOrgDept")
	@ResponseBody
	public List<OrgDeptExtend> selectAllOrgDept(){
		return signCardSingleService.selectAllOrgDeptService();
	}
	
	@RequestMapping("/selectOrgDeptByPkHrorg")
	@ResponseBody
	public List<OrgDeptExtend> selectOrgDeptByPkHrorg(String pkHrorg){
		return signCardSingleService.selectOrgDeptByPkHrorgService(pkHrorg);
	}
	
	/**
	 * 根据部门主键获取人员
	 * @param pkDepts
	 * @return
	 */
	@RequestMapping("/getDeptPsndoc")
	@ResponseBody
	public List<BdPsndoc> getDeptPsndoc(@RequestParam("pkDepts[]") List<String> pkDepts){
		return signCardSingleService.getDeptPsndocService(pkDepts) ;
	}
	
	/**
	 * 根据条件获取签卡单信息
	 * @param conditionSelectTbmSignhEntit
	 * @return
	 */
	@RequestMapping("/conditionSelectTbmSignh")
	@ResponseBody
	public DataGridData conditionSelectTbmSignh(ConditionSelectTbmSignhEntity conditionSelectTbmSignhEntit){
		
		return signCardSingleService.conditionSelectTbmSignhService(conditionSelectTbmSignhEntit);
	}
	
	/**
	 * 根据签卡单主键获取子表信息
	 * @param tbmSignhExtend
	 * @return
	 */
	@RequestMapping("/getTbmSignbByPkSignh")
	@ResponseBody
	public DataGridData getTbmSignbByPkSignh(@RequestBody TbmSignhExtend tbmSignhExtend){
		
		return signCardSingleService.getTbmSignbByPkSignhService(tbmSignhExtend);
	}
	
	/**
	 * 删除子表
	 * @param tbmSignbExtends
	 * @return
	 */
	@RequestMapping("/deleteTbmSignb")
	@ResponseBody
	public DataGridData deleteTbmSignb(@RequestBody List<TbmSignbExtend> tbmSignbExtends){
		
		return signCardSingleService.deleteTbmSignbService(tbmSignbExtends);
	}
	
	/**
	 * 删除主表
	 * @param tbmSignhExtends
	 * @return
	 */
	@RequestMapping("/deleteTbmSignh")
	@ResponseBody
	public DataGridData deleteTbmSignh(@RequestBody List<TbmSignhExtend> tbmSignhExtends){
		
		return signCardSingleService.deleteTbmSignhService(tbmSignhExtends);
	}
	
	/**
	 * 查询签卡原因
	 * @return
	 */
	@RequestMapping("/getBdDefdoc") 
	@ResponseBody
	public List<BdDefdoc> getBdDefdoc(){
		
		return signCardSingleService.getBdDefdocService();
	}
	
	/**
	 * 修改签卡详情
	 * @param tbmSignbExtend
	 * @return
	 */
	@RequestMapping("/updateTbmSignbByPkSignb") 
	@ResponseBody
	public ReturnMessageData updateTbmSignbByPkSignb(@RequestBody TbmSignbExtend tbmSignbExtend){
		
		return signCardSingleService.updateTbmSignbByPkSignbService(tbmSignbExtend);
	}
	
	@RequestMapping("{page}")
	public String skipPage(@PathVariable("page") String page) {
		return "signCardSingle/"+page;
	}
}
